<?php  
class ControllerStoresProductList extends Controller {
	public function index() {
		$this->document->setTitle($this->config->get('config_title'));
		$this->document->setDescription($this->config->get('config_meta_description'));
		
		$this->data['heading_title'] = $this->config->get('config_title');
		$store_id = $this->request->get['store-id'];
		$this->load->model('stores/category');	
		$this->load->model('stores/product');
		if(!empty($store_id)){
			
			$categories_store = $this->model_stores_category->getCategoriesBystoreid($store_id);
			//print_r($categories_store);
			foreach($categories_store as $key => $value){
				//$products[$value['name']] = $this->model_stores_product->getProductsByCategoryId($value['category_id']);
				$categories_store[$key]['products'] = $this->model_stores_product->getProductsByCategoryId($value['category_id']);
			}
			
			$this->data['productlist'] = $categories_store;
			
		}
	
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/stores/productlist.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/stores/productlist.tpl';
		} else {
			$this->template = 'default/template/stores/productlist.tpl';
		}
		
		$this->children = array(
			'common/column_left',
			'common/column_right',
			'common/content_top',
			'common/content_bottom',
			'common/footer',
			'common/header'
		);
										
		$this->response->setOutput($this->render());
	}
}
?>